<?php
	require_once(dirname(__FILE__)."/xheditor/serverscript/php/ubb2html.php");
	require_once(dirname(__FILE__)."/include/blog_display_data.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh" xml:lang="zh">

<head>
	<title>解题报告浏览</title>
	<link rel="stylesheet" type="text/css" href="css/common.css" />
	<script type="text/javascript" src="./js/show_subtitle.js"></script>
	<script type="text/javascript" src="./xheditor/jquery/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="./xheditor/xheditor-1.2.1.min.js"></script>
	<script type="text/javascript" src="./xheditor/xheditor_init.js"></script>
	<script type="text/javascript" src="./xheditor/xheditor_lang/zh-cn.js"></script>
	<script type="text/javascript" src="./xheditor/xheditor_plugins/ubb.js"></script>
	<script type="text/javascript" src="./js/cpp_coderender.js"></script>
	<script type="text/javascript" src="./js/utility.js"></script>
	<script type="text/javascript">
		var editor;
		$(document).ready(function(){
			var codeTag = document.getElementsByTagName("code");
			for (var i = 0; i < parseInt(codeTag.length); ++i)
			{
				obj = codeTag.item(i);
				codeText = hexToStr(obj.innerHTML);
				obj.innerHTML = renderCode(codeText);
			}

			editor = $("#msg").xheditor({tools:'simple', width:700, height:250,beforeSetSource:ubb2html,beforeGetSource:html2ubb});
		});
	</script>
	<style>
		.subtitle{
				font-weight: blod;
				font-size: 15px;
				color: #666666;	
				float:left;
				list-style:none;
				width: 90px;
			}
		.subtitle_v{
			font-weight: blod;
			font-size: 15px;
			color: #666666;	
			list-style:none;
		}
		.common_btn{
			margin:0px 0px 0px 0px;
			padding:8px 2px 5px 2px;
			width:120px;
			text-align:center;
			background-color:#ffffff;
			color: green;
			cursor:pointer;
		}
	</style>
</head>

<body>
	<table align="center" style="width:<?php echo $width;?>" border="0">
		<tr>
			<td><?php require_once("./header.php"); ?></td>
		</tr>
		<tr>
			<td id="content">
				<table align="center" style="width:95%; padding:30px 0px 0px 20px;background-color:#ffffff;" border="0">
					<tr>
						<td style="padding-bottom: 10px">
							<div style="font-size:18px;color:black;padding:8px 0px 10px 10px;height:30px; ">
								<div style="float:left;"><img src="./skins/blog_logo.gif" atl="logo" /></div>
								<div style="float:left;font-size:20px; padding: 5px 0px 0px 10px">
									<a href="./blog_home.php">算法解题</a>
									<span style="font-size:12px"> > </span>
									<?php echo $BlogItem->title; ?>
								</div>
								<div style="float:left;padding: 15px 0px 0px 20px">
									<span style="font-size:12px;color:green"><?php echo $BlogItem->in_time; ?> (<?php echo $BlogItem->user; ?>)
									</span>
								</div>
								
								<?php
									if (isset($_SESSION["user"]) && ($_SESSION["user"] == $BlogItem->user || isset($_SESSION["admin"]))){ 
								?>
								<div style="float:left; padding: 10px 0px 0px 20px">
									<?php if ($_SESSION["user"] == $BlogItem->user){ ?>
										<a style="color:#f90;font-size:12px" href="./blog_edit_page.php?bid=<?php echo $BlogItem->id;?>">编辑</a>
									<?php } ?>
									&nbsp;
									<a style="color:#f90;font-size:12px" href="./include/blog_dele_data.php?bid=<?php echo $BlogItem->id;?>">删除</a>
								</div>
								<?php } ?>

								<div id="bloglist" onmouseover="ShowObject('bloglist')" onmouseout="HideObject('bloglist')" class="listpanel">
									<?php 
										foreach($KeyWithList as $Object){
									?>
									<p class='listitem'>> 
										<a href="./blog_display.php?bid=<?php echo $Object->id; ?>">
											<?php echo $Object->title."(".$Object->user.")"; ?>
										</a>
									</p>
									<?php }?>
									<?php
										if (count($KeyWithList) == 0)
										{
											echo "<p class='listitem'>暂无其他的提交记录~~</p>";
										}
									?>
									<p class='listitem bold'>>
										<a href="blog_list_display.php?search=<?php echo $BlogItem->keyword; ?>">
											查看全部	
										</a>
									</p>
								</div>
								
								<div onmouseover="CreateBlogList()" onmouseout="HideObject('bloglist')" style="float:right;" id="tag">
									<p class="common_btn" >更多解法</p>
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td style="padding: 10px 0px 10px 10px">
							<div>
								<li class="subtitle">算法类型: </li>
								<?php 
									foreach($BlogItem->classlist as $Object){
								?>
									<li style="list-style:none; float:left; width: 80px; ">
										<a href="./blog_list_display.php?cid=<?php echo $Object->id; ?>"><i><?php echo $Object->name; ?></i></a>
									</li>
								<?php 
									}
								?>
							</div>
						</td>
					</tr>
					<tr>
						<td style="padding: 10px 0px 20px 10px; border-bottom:dashed 1px green; ">
							<div>
								<li class="subtitle">关键字表: </li>
								<?php
									foreach($KeyArr as $key){
								?>
								<li style="list-style:none; float:left; padding-right:20px">
									<a href="blog_list_display.php?keyword=<?php echo $key; ?>">
									<i><?php echo $key; ?></i>
									</a>
								</li>
								<?php } ?>
							</div>
						</td>
					</tr>
					<tr>
						<td style="padding:30px 0px 20px 10px;border-bottom:dashed 1px green" valign="top">
							<div id = "blog_content" style="padding-left: 0px; min-height:200px; ">
								<?php 
									echo ubb2html($BlogItem->content);
								 ?>
							</div>
						</td>
					</tr>
					<?php if (count($MsgList) > 0){ ?>
					<tr>
						<td style="padding:0px 0px 0px 10px;" valign="top">
							<div id = "msglist">
								<p class="subtitle_v">留言板</p>
								<?php foreach ($MsgList as $Object) {
								?>
									<div class="msg_listitem">
										<div class="msg_title">
											<span style="color:green;">[<?php echo $Object->in_time; ?>]</span> # 
											<a href="./userinfo.php?user=<?php echo $Object->user; ?>"><?php echo $Object->user; ?></a> &nbsp;
											<?php if ($Object->user == $_SESSION["user"] || $BlogItem->user == $_SESSION["user"]){ ?>
												<span id="msg_listitem_edit"><a href="./include/msg_delete_data.php?id=<?php echo $Object->id; ?>">删除</a></span>
											<?php } ?>
										</div>
										<div class="msg_listitem_content">
											<?php echo ubb2html($Object->msg); ?>
										</div>
									</div>
								<?php } ?>
							</div>
						</td>
					</tr>
					<?php } ?>
					<tr>
						<td style="padding:20px 0px 0px 10px" valign="top">
							<form action="./blog_display.php#msglist" method="post">
								<input type="hidden" name="bid" value="<?php echo $BlogItem->id; ?>"/>
								<div>
									<p class="subtitle_v"> 想要说点什么呢？（最大10000字）</p>
									<p><textarea id="msg" name="msg" ></textarea></p>
									<input type="submit" name="msg_add" value="提交" />
								</div>
							</form>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td style="padding-top:50px"><?php require_once("./footer.php"); ?></td>
		</tr>
</body>
</html>